<template>
	<view class="">
		
		<u-navbar title="资讯详情" bgColor="#c30d23" :titleStyle="titleStyle" leftIconColor="#ffffff" :autoBack="true" safeAreaInsetTop placeholder>
		</u-navbar>
		<view class="title">
			{{title}}
		</view>
		<view class="f-between-center" style="padding: 24rpx 0;color: #999;">
			<view class="">来源：{{textFrom}}</view>
			<view class="">阅读数：{{hits}}</view>
		</view>
		<view class="" v-html="text">
			
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				titleStyle: {
					color: "#ffffff",
					fontSize: "36rpx",
					fontWeight: '400'
				},
				text:'',
				title:'',
				textFrom:"",
				hits:''
			}
		},
		onLoad(e) {
			console.log(e.id)
			this.getData(e.id)
		},
		methods:{
			getData(e){
				uni.request({
					url:'http://8.130.69.63:8280/api/Common/QueryNewContents?ids='+e,
					method:"GET",
					success: (res) => {
						console.log(res.data)
						this.text = res.data.data[0].context
						this.title = res.data.data[0].title
						// this.textFrom = res.data.data[0].creaedate
						const updateTime = new Date(res.data.data[0].creaedate);
						const month = updateTime.getMonth() + 1; // Months are zero-indexed
						const day = updateTime.getDate();
												
						// Pad single-digit months or days with a leading zero
						const formattedMonth = month < 10 ? `0${month}` : month;
						const formattedDay = day < 10 ? `0${day}` : day;
												
						// Add 'time' property in the format 'MM-DD'
						this.textFrom = `${formattedMonth}-${formattedDay}`;
						this.hits = res.data.data[0].hits
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.title{
		font-size: 38rpx;
		color: #333333;
		font-weight: bold;
		margin-top: 30rpx;
	}
	page{
		box-sizing: border-box;
		padding: 0 30rpx;
		background: #fff;
	}
</style>